<template>
  <div class="app-container">
    <el-dialog :wrapperClosable="false" :close-on-press-escape="false" title="打款校验" @closed="close" :visible.sync="open" width="35%" append-to-body>
      <el-form v-loading = "loading" ref="form" :rules="rules" :model="form" label-width="110px" class="form">
        <el-form-item label="回款金额" prop="receiveAmount">
          <el-input-number :step="0.1" :min="0.01" :max="100" :precision="2" v-model.number="form.receiveAmount" placeholder="请输入回款金额" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveForm">确 定</el-button>
        <el-button @click="open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
let isRefresh = false
import { accountBindVerify } from '@/api/ecs/dinPay'
export default {
  name: "accountBindVerify",
  props: {
    opens: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      rules:{
        receiveAmount:[
          {required:true,message:"请输入回款金额",trigger:"blur"}
        ]
      },
      form:{receiveAmount:"",bankCardId:"",id:""},
      open:false,
      loading:false
    }
  },
  methods:{
    close(){
      this.$emit("close",false,isRefresh)
    },
    saveForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          accountBindVerify(this.form).then(response => {
            if (response.code === 200){
              isRefresh = true
            }
          })
        }
      })
    }
  },
  watch: {
    opens: {
      handler(val) {
        this.open = val
        this.form.id = this.formData.id
        this.form.bankCardId = this.formData.bankCardId
        this.form.receiveAmount = this.formData.receiveAmount
      },
      deep: true,
      immediate: true
    },
  }
}

</script>
<style scoped lang="scss">

</style>
